import logging

log_obj=logging.getLogger('sunny product')
log_obj.setLevel(10)

handler=logging.StreamHandler()
handler2=logging.FileHandler('./test.log','a',encoding='utf-8')#文件的handler

log_fom=logging.Formatter("%(asctime)s__%(name)s__%(levelname)s__%(message)s")

handler.setFormatter(log_fom)
handler.setLevel(20)

handler2.setFormatter(log_fom)
handler2.setLevel(20)


log_obj.addHandler(handler2)

log_obj.debug("debug")
log_obj.info("info")
log_obj.error("error")
log_obj.warning("warning")
log_obj.critical("critical")
